<?php 
session_start();
if (isset($_SESSION['uid'])){
    $uid=$_SESSION['uid'];
}else{
    exit;
}
include './c/config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
$sql="SELECT * FROM `app_student` where id='".$uid."' limit 0,1 "; 
$query=$mysqli->query($sql);
if($query->num_rows>0){
    $userInfo=array();
    while ($list=$query->fetch_assoc()){
        $userInfo=$list;
    }
}else{
    exit;
}
header('Content-type: image/jpeg');
$title=file_get_contents('./c/ti.txt');
$image = new Imagick('./img/print.jpg');
$color = new ImagickPixel('#000000');
$draw = new ImagickDraw();
$draw->settextkerning(2);
$draw->setFont('msyh.ttf');
$draw->setFontSize(40);
$draw->setFillColor($color);
$draw->setTextAntialias(true);
$draw->annotation(370, 1438, $userInfo['name']);
$draw->annotation(1370, 1438, $userInfo['school']);
$draw->annotation(370, 1548, $userInfo['nianji']);
$draw->annotation(1378, 1548, $userInfo['idcard']);
$draw->annotation(370, 1648, $userInfo['kc']);
$draw->annotation(1370, 1648, '2018年12月08日下午13:30-15:00');
$draw->annotation(370, 1752, '上海商业会计学校');
$draw->annotation(1370, 1754, $userInfo['dizhi']);
$draw->annotation(370, 1856, '地铁8号线、9号线；43路、66路公交车');
$colorTwo = new ImagickPixel('#ae1f25');
$draw->setFontSize(48);
$draw->setFontWeight(800);
$draw->setFillColor($colorTwo);
$draw->annotation(390, 1358, $userInfo['hao']);

$draw->setFontSize(58);
$draw->setFontWeight(900);
$draw->setFillColor($colorTwo);
$draw->annotation(130, 1280, $title);

$image->drawimage($draw);
file_put_contents('./pic/'.$uid.'.jpg', $image);

echo  json_encode(array('status'=>'ok'));
?>